export function Singleton(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) {
  const method = descriptor.value;
  const symbol = Symbol(propertyName);

  if (typeof method !== 'function') {
    throw new Error(`@Singleton can only be applied to methods not: ${typeof method}`);
  }

  descriptor.value = function (...args: any[]) {
    if (!this[symbol]) {
      this[symbol] = method.apply(this, args);
    }
    return this[symbol];
  };

  return descriptor;
}